package com.qezhhnjy.bilibili.service.impl;

import cn.hutool.core.util.IdUtil;
import com.qezhhnjy.bilibili.service.MessageProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;


/**
 * @author zhaoyangfu - 2021/4/5 17:04
 */
// 定义消息的推送管道
@EnableBinding(Source.class)
@Slf4j
public class MessageProviderImpl implements MessageProvider {

    // 消息发送管道
    @Resource
    private MessageChannel output;

    @Override
    public String send() {
        String serial = IdUtil.simpleUUID();
        output.send(MessageBuilder.withPayload(serial).build());
        log.info("serial=>{}", serial);
        return serial;
    }
}
